﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>

    <a id="frozenLink" href="#">How many times can you click me?</a>


    
    <!-- based on http://jsfiddle.net/TrevorBurnham/GCbHm/ -->
    <script>
        var clickCount = 0,
            link;
        link = document.getElementById('frozenLink')
        link.innerHTML = 'How many times can you click me?';
        link.onclick = function () {
            clickCount++;
            link.onclick = function () { clickCount++; };

            start = new Date();
            while (new Date() - start < 2000) { }
            console.log(clickCount);  // this will always be 1

            setTimeout(function () {
                link.innerHTML = 'You clicked me ' + clickCount + ' times. Ow!';
            }, 0);
        };

    </script>
</body>
</html>
